home *** CD-ROM | disk | FTP | other *** search
- { message.pas -- A menu with messages }
-
- program Message;
-
- {$R menu.res}
-
- uses WinTypes, WinProcs, WObjects, Strings;
-
- const
-
- id_Menu = 100; {- Menu resource ID }
- cm_FileNew = 101; {- Command resource IDs }
- cm_FileOpen = 102;
- cm_FileExit = 103;
-
- type
-
- MsgApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PMsgWindow = ^MsgWindow;
- MsgWindow = object(TWindow)
- constructor Init(AParent: PWindowsObject; ATitle: PChar);
- procedure CMFileNew(var Msg: TMessage);
- virtual cm_First + cm_FileNew;
- procedure CMFileOpen(var Msg: TMessage);
- virtual cm_First + cm_FileOpen;
- procedure CMFileExit(var Msg: TMessage);
- virtual cm_First + cm_FileExit;
- end;
-
- { MsgApplication }
-
- {- Initialize the application's window }
- procedure MsgApplication.InitMainWindow;
- begin
- MainWindow := New(PMsgWindow, Init(nil, 'Message Menu'))
- end;
-
- { MsgWindow }
-
- {- Initialize the application's window object }
- constructor MsgWindow.Init(AParent: PWindowsObject; ATitle: PChar);
- begin
- TWindow.Init(AParent, ATitle);
- Attr.Menu := LoadMenu(HInstance, PChar(id_Menu))
- end;
-
- {- Process File:New command }
- procedure MsgWindow.CMFileNew(var Msg: TMessage);
- begin
- MessageBox(HWindow, 'New command', 'Message Box', mb_Ok)
- end;
-
- {- Process File:Open command }
- procedure MsgWindow.CMFileOpen(var Msg: TMessage);
- begin
- MessageBox(HWindow, 'Open command', 'Message Box', mb_Ok)
- end;
-
- {- Process File:Exit command }
- procedure MsgWindow.CMFileExit(var Msg: TMessage);
- begin
- MessageBox(HWindow, 'Exit command', 'Message Box', mb_Ok);
- CloseWindow
- end;
-
- var
-
- MsgApp: MsgApplication;
-
- begin
- MsgApp.Init('MsgApp');
- MsgApp.Run;
- MsgApp.Done
- end.
-
-
- { --------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 1/11/91
- ------------------------------------------------------------- }
-